package cn.zjk.test.common;

import cn.zjk.springframework.beans.BeansException;
import cn.zjk.springframework.beans.factory.config.BeanPostProcessor;
import cn.zjk.test.bean.TestService;

/**
 * @description:
 * @Author zjk
 * @className: MyBeanPostProcessor
 * @date: 2023/3/28 16:42
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if("testService".equals(beanName)){
            TestService testService = (TestService) bean;
            testService.setLocation("修改为：江苏省苏州市");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}
